﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using WalkingTec.Mvvm.Core;
using System.Text.Json.Serialization;
using nERP.Model;
using nERP.Model._Admin;
using nERP.Model.Wms;

namespace nERP.Model.Wms
{
    /// <summary>
    /// 其他出库
    /// </summary>
	[Table("OtherOutWarehouse")]
    [SoftKey(nameof(OtherOutWarehouse.OtherOutWarehouseCode))]
    [Display(Name = "_Model.OtherOutWarehouse")]
    public class OtherOutWarehouse : BasePoco,IPersistPoco,ITenant,IWorkflow
    {
        [Display(Name = "_Model._OtherOutWarehouse._OtherOutWarehouseCode")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("出库单号")]
        [Required(ErrorMessage = "Validate.{0}required")]
        [CanNotEdit]
        public string OtherOutWarehouseCode { get; set; }
        [Display(Name = "_Model._OtherOutWarehouse._OtherOutType")]
        [Comment("业务类别")]
        [RefDicName(Name = "出库业务类别")]
        public DicField OtherOutType { get; set; }
        [Display(Name = "_Model._OtherOutWarehouse._OtherOutType")]
        [Comment("业务类别")]
        public Guid? OtherOutTypeId { get; set; }
        [Display(Name = "_Model._OtherOutWarehouse._MakeUser")]
        [Comment("制单人")]
        [NotMapped]
        public FrameworkUser MakeUser { get; set; }
        [Display(Name = "_Model._OtherOutWarehouse._MakeUser")]
        [StringLength(32, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("制单人")]
        public string MakeUserId { get; set; }
        [Display(Name = "_Model._OtherOutWarehouse._InvoicesDate")]
        [Comment("单据日期")]
        public DateTime? InvoicesDate { get; set; }
        [Display(Name = "_Model._OtherOutWarehouse._Status")]
        [Comment("单据状态")]
        public StatusTypeEnum? Status { get; set; }
        [Display(Name = "_Model._OtherOutWarehouse._InvoicesImage")]
        [Comment("单据附件")]
        public List<OtherOutWarehouseInvoicesImage> InvoicesImage { get; set; }
        [Display(Name = "_Model._OtherOutWarehouse._Remark")]
        [StringLength(256, ErrorMessage = "Validate.{0}stringmax{1}")]
        [Comment("备注")]
        public string Remark { get; set; }
        [Display(Name = "_Model._OtherOutWarehouseDetail._OtherOutWarehouse")]
        [InverseProperty("OtherOutWarehouse")]
        [NotMapped]
        [SoftFK(nameof(nERP.Model.Wms.OtherOutWarehouseDetail.OtherOutWarehouseId))]
        public List<OtherOutWarehouseDetail> OtherOutWarehouseDetail_OtherOutWarehouse { get; set; }
        [Display(Name = "_Model._OtherOutWarehouse._IsValid")]
        [Comment("是否有效")]
        [Required(ErrorMessage = "Validate.{0}required")]
        public bool IsValid { get; set; } = true;
        [StringLength(50, ErrorMessage = "Validate.{0}stringmax{1}")]
        public string TenantCode { get; set; }

	}
    public class OtherOutWarehouseInvoicesImage : TopBasePoco, ISubFile
    {
        public Guid OtherOutWarehouseId { get; set; }
        public OtherOutWarehouse OtherOutWarehouse { get; set; }
        public Guid FileId { get; set; }
        public FileAttachment File { get; set; }
        public int Order { get; set; }
    }

}
